import java.util.ArrayList;
import java.util.Stack;

public class Solution {
    public boolean IsPopOrder(int [] pushA,int [] popA) {
        Stack<Integer> stack = new Stack<>();
        int lenA=pushA.length;
        int lenB=lenA;
        int p=0;
        int o=0;
        for(int i=0;i<lenA;i++) {
            stack.push(pushA[i]);
            while(!stack.isEmpty() && stack.peek()==popA[o]) {
                stack.pop();
                o++;
            }
        }
        return stack.isEmpty();
    }
}